#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int months[12] = { 31,29,31,30,31,30,31,31,30,31,30,31 };
int ret = 0;

int is_leapyear(int y) {
	if ((y % 4 == 0 && y % 100 != 0) || (y % 400 == 0)) {
		return 1;
	}
	else return 0;
}

void count_days(int m, int d) {
	for (int i = 0; i < m - 1; i++) {
		ret += months[i];
	}
	ret += d;
}
int main() {
	
	int y, m, d;
	scanf("%d %d %d", &y, &m, &d);

	if (is_leapyear(y)) {
		count_days(m, d);
	}
	else {
		(*(months + 1))--;
		 count_days(m, d);

	}
	printf("%d", ret);

	return 0;
}